package components.appearance;

import com.uqbar.vainilla.appearances.Animation;
import com.uqbar.vainilla.appearances.Appearance;
import com.uqbar.vainilla.appearances.Sprite;

public class LinealAnimation extends Animation {

	public LinealAnimation(double meantime, Sprite[] sprites) {
		super(meantime, sprites);
	}

	@Override
	protected void advance() {
		this.setCurrentIndex(this.getCurrentIndex() + 1);

		if(this.getCurrentIndex() >= this.getSprites().length) {
			Sprite[] sps = new Sprite[1];
			sps[0] = this.getSprites()[this.getCurrentIndex()-1];
			this.setCurrentIndex(0);
			this.setSprites(sps);
		}

		this.setRemainingTime(this.getMeantime() - this.getRemainingTime());
	}
	
}
